package com.yw.android.common.utils;

import android.content.Context;

import java.io.InputStream;


public class FileUtils {

    public static String getAssetsData(Context mContext, String fileName) {
        String result = "";
        try {
            //获取输入流
            InputStream mAssets = mContext.getAssets().open(fileName);

            //获取文件的字节数
            int lenght = mAssets.available();
            //创建byte数组
            byte[] buffer = new byte[lenght];
            //将文件中的数据写入到字节数组中
            mAssets.read(buffer);
            mAssets.close();
            result = new String(buffer);
            return result;
        } catch (Throwable e) {
            LOG.e("[fileName : " + fileName + "] (Throwable)", e);
            return "";
        }
    }
}
